//Init module if you need
let map
let stack = []
function Init()
{
    // write code here
    map = new Map()
}
//Insert one char from stringstream
function Insert(ch)
{
    // write code here
    if(map.has(ch)){
      map.set(ch,map.get(ch)+1)
      let index = stack.indexOf(ch)
      if(index !== -1){
        stack.splice(index,1)
      }
    }else{
      map.set(ch,1)
      stack.push(ch)
    }
}
//return the first appearence once char in current stringstream
function FirstAppearingOnce()
{
    // write code here
    return stack.length ? stack[0] : '#'
}

module.exports = {
	Init : Init,
    Insert : Insert,
    FirstAppearingOnce: FirstAppearingOnce
};